import { request } from '@/utils'

// 登录
export function loginAPI(formData) {
    return request({
        url: '/login',
        method: 'POST',
        data: formData
    })
}

// 自动登录，token设置一天有效期
export function autoLoginAPI({account,dwmc}) {
    return request({
        url: `/autologin?username=${account}&dwmc=${dwmc}`,
        method: 'GET',
    })
}

// 搜索
export function searchAPI({ searchInput, searchType, searchCompanyType , pageNum = 1, pageSize = 10 }) {
    return request({
        url: `/search?searchInput=${searchInput}&searchType=${searchType}&pagenum=${pageNum}&resultcount=${pageSize}&searchCompanyType=${searchCompanyType}`,
        method: 'GET',
    })
}
// 获取数据仓库中各表信息
export function wareHouseAPI({ dataType, pageNum = 1, pageSize = 10 , company = ''}) {
    // return request({
    //     url: `/ware-house?dataType=${dataType}&pagenum=${pageNum}&pagesize=${pageSize}&company=${company}`,
    //     method: 'GET',
    // })
    const query = new URLSearchParams({
        dataType,
        pagenum: pageNum,
        pagesize: pageSize,
        company
    }).toString();
    return request({
        url: `/ware-house?${query}`,
        method: 'GET',
    });
}

// 获取数据仓库中贸易风险信息
export function riskTitleAPI({ dataType, pageNum = 1, pageSize = 10 , keyword = '', year = '', fxlx = ''}) {
    // return request({
    //     url: `/ware-house?dataType=${dataType}&pagenum=${pageNum}&pagesize=${pageSize}&company=${company}`,
    //     method: 'GET',
    // })
    const query = new URLSearchParams({
        dataType,
        pagenum: pageNum,
        pagesize: pageSize,
        company: keyword,
        year,
        fxlx
    }).toString();
    return request({
        url: `/ware-house?${query}`,
        method: 'GET',
    });
}
// 首页面（包含工商基本信息、股东信息、风险标签、上游企业TOP5、下游企业TOP5、历史风险信息）
export function portraitAPI({ company }) {
    return request({
        url: `/user-portrait?company=${company}`,
        method: 'GET',
    })
}
// 经营风险&司法风险
export function portraitfxxxAPI({ company,type }) {
    return request({
        url: `/portrait_fxxx?company=${company}&type=${type}`,
        method: 'GET',
    })
}
// 工商风险信息-经营风险
export function businessriskAPI({ pagenum,pagesize,risktype }) {
    return request({
        url: `/business-risk?pageNum=${pagenum}&pageSize=${pagesize}&riskType=${risktype}`,
        method: 'GET',
    })
}
// 工商风险信息-司法风险
export function judicialriskAPI({ pagenum,pagesize,risktype }) {
    return request({
        url: `/judicial-risk?pageNum=${pagenum}&pageSize=${pagesize}&riskType=${risktype}`,
        method: 'GET',
    })
}
// 工商风险信息-搜索
export function risksearchAPI({ pagenum,pagesize,riskType,companyName }) {
    return request({
        url: `/risk-search?pageNum=${pagenum}&pageSize=${pagesize}&riskType=${riskType}&companyName=${companyName}`,
        method: 'GET',
    })
}
// 司库核实函信息
export function sikuhshsearchAPI({ pagenum,pagesize }) {
    return request({
        url: `/findall?pageNum=${pagenum}&pageSize=${pagesize}`,
        method: 'GET',
    })
}
// 批量删除
export function sikuhshdeleteallAPI({ params }) {
    return request({
        url: `/delall`,
        method: 'DELETE',
        data: params
    })
}
// 司库核实函中间表信息
export function sikuhshsearchtplAPI({ pagenum,pagesize }) {
    return request({
        url: `/findtplall?pageNum=${pagenum}&pageSize=${pagesize}`,
        method: 'GET',
    })
}
// 批量删除中间表
export function sikuhshdeletealltplAPI({ params }) {
    return request({
        url: `/deltplall`,
        method: 'DELETE',
        data: params
    })
}
// 上传核实函文件
export function sikuhshuploadAPI(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: `/uploaddata`,
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}
// 上传核实函文件到中间表
export function sikuhshuploadtplAPI(file) {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: `/uploadtpldata`,
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}
// 核实函查询
export function sikuhshblurfindAPI({company, jylx, pagenum, pagesize}) {
    return request({
        url: `/blurfind?company=${company}&jylx=${jylx}&pageNum=${pagenum}&pageSize=${pagesize}`,
        method: 'GET',
    })
}
// 清空数据
export function sikuhshclearAPI(){
    return request({
        url: `/clear`,
        method: 'DELETE'
    })
}
// 查询符合时间区间的数据
export function timeintervaldataAPI({type, start_time, end_time, pageNum, pageSize}){
    return request({
        url: `/timeintervaldata?type=${type}&start_time=${start_time}&end_time=${end_time}&pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'GET',
    })
}
// 查询符合时间区间的中间表数据
export function timeintervaltpldataAPI({type, start_time, end_time, pageNum, pageSize}){
    return request({
        url: `/timeintervaltpldata?type=${type}&start_time=${start_time}&end_time=${end_time}&pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'GET',
    })
}
// 资金风险-TAB
// export function capitalriskAPI({ company, startDate, endDate }) {
//     return request({
//         url: `/capital-risk?company=${company}&start_date=${startDate}&end_date=${endDate}`,
//         method: 'GET',
//     })
// }
export function capitalriskAPI({ company, year,is_cydw }) {
    return request({
        url: `/capital-risk?company=${company}&year=${year}&is_cydw=${is_cydw}`,
        method: 'GET',
    })
}
// 交易特征 获取交易指标、交易统计数据
export function transactionAPI({ company, year, companytype }) {
    return request({
        url: `/transactionCharacters?companyName=${company}&company_type=${companytype}&year=${year}`,
        method: 'GET',
    })
}
// 交易特征 图谱-资金流向
export function fundflowAPI({ company, year, companytype, type }) {
    return request({
        url: `/fund_flow?company=${company}&is_cydw=${companytype}&year=${year}&type=${type}`,
        method: 'GET',
    })
}
// 对手特征 获取对手特征、对手规模&成员单位、对手地域、对手行业数据
export function opponentAPI({ company, startDate, endDate, companytype }) {
    return request({
        url: `/opponentCharacters?companyName=${company}&company_type=${companytype}&start_date=${startDate}&end_date=${endDate}`,
        method: 'GET',
    })
}
// 对手特征 图谱-交易社群
export function tradecrowdAPI({ company, startDate, endDate, companytype}) {
    return request({
        url: `/trade_crowd?company=${company}&is_cydw=${companytype}&start_date=${startDate}&end_date=${endDate}`,
        method: 'GET',
    })
}
// 结算偏好 获取交易指标、结算统计数据
export function settlementAPI({ company, startDate, endDate, companytype }) {
    return request({
        url: `/settlementPreference?companyName=${company}&company_type=${companytype}&start_date=${startDate}&end_date=${endDate}`,
        method: 'GET',
    })
}
// 报告生成
export function exportgenerateAPI({ company }) {
    return request({
        url: `/report_generation?company_name=${company}`,
        method: 'GET'
    })
}
// 集团数据预载
export function calculationAPI(){
    return request({
        url: `/calcu`,
        method: 'GET'
    })
}